package com.stu.student_back_end.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stu.student_back_end.entity.TblDorm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 宿舍mapper层接口
 */

@Mapper
public interface TblDormMapper extends BaseMapper<TblDorm> {

    //查询宿舍数
    @Select("select count(*) from tbl_dorm")
    int queryDormCount();

    //查询楼栋人数
    @Select("select ifnull(sum(type - freeBeds),0) from tbl_dorm where buildName = #{buildName}")
    int queryDormBuildingCount(@Param("buildName") String buildName);
}
